<template>
    <div>
        <el-dialog title="编辑角色" :visible.sync="editDialog" width="30%" :before-close="editHandleClose">
            <el-form :model="roleInfo" label-width="80px">
                <el-form-item label="角色名称">
                    <el-input v-model="roleInfo.roleName"></el-input>
                </el-form-item>
                <el-form-item label="角色描述">
                    <el-input v-model="roleInfo.roleDes"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="editHandleClose">取 消</el-button>
                <el-button type="primary" @click="editSumbit">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>
<script>
export default {
    data() {
        return {

        }
    },
    props: {
        editDialog: {
            type: Boolean,
            default: false
        },
        roleInfo: {
            type: Object,
            default: {}
        }
    },
    methods: {
        //保存页面提交
        editSumbit() {
            let newRoleInfo = this.roleInfo;
            let data = {
                "roleId": newRoleInfo.roleId,
                "roleName": newRoleInfo.roleName,
                "roleDes": newRoleInfo.roleDes
            }
            this.$http({
                method: 'post',
                url: 'admin/role/update',
                Headers: {
                    'Content-Type': 'application/json'
                },
                data: data
            }).then(res => {
                let result = res.data;
                if (result.code == 200) {
                    this.$message({
                        type: 'success',
                        message: '操作成功'
                    })
                    this.editHandleClose();
                }
            })

        },
        //关闭弹窗方法
        editHandleClose() {
            this.$emit("editDialogFormVisible", false);
        }
    }

}
</script>